package com.example.client.message;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class Receiver {

//    @RabbitListener(queues = "MyQueue")
//      @RabbitListener(queuesToDeclare = @Queue("MyQueue2"))
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("MyQueue"),
            exchange = @Exchange("MyExchange")
    ))
        public void receive(String message) {

        log.info("receive message : {}" , message);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("MyQueue"),
            key = "fruit",
            exchange = @Exchange("MyExchange")
    ))
    public void receiveFruit(String message) {
        log.info("receive fruit : {}" , message);
    }


    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("MyQueue"),
            key = "cd",
            exchange = @Exchange("MyExchange")
    ))
    public void receiveCd(String message) {
        log.info("receive cd : {}" , message);
    }
}
